package cn.openea.perpartner.payment.web.order.service.impl;

import cn.hutool.core.util.StrUtil;
import cn.openea.perpartner.payment.web.order.entity.dto.SearchDto;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.openea.perpartner.payment.web.order.mapper.OrderMapper;
import cn.openea.perpartner.payment.web.order.entity.Order;
import cn.openea.perpartner.payment.web.order.service.IOrderService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (Order)表服务实现类
 *
 * @author Weird077
 * @since 2023-01-28 11:59:44
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {

    @Override
    public List<Order> selectList(SearchDto dto) {
        LambdaQueryWrapper<Order> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Order::getCreateUser,dto.getUserId());
        if(StrUtil.isNotBlank(dto.getOrderType())){
            wrapper.eq(Order::getOrderType,dto.getOrderType());
        }
        wrapper.orderByDesc(Order::getCreateTime);
        return list(wrapper);
    }
}

